#include<iostream>
#include<pthread.h>
#include<string>
#include<unistd.h>

using namespace std;

void* callback1(void* arg)
{
  string str=(char*)arg;
  while(1)
  {
    cout<<str<<endl;
    sleep(10);
  }

}

void* callback2(void* arg)
{

  string str=(char*)arg;
  while(1)
  {
    cout<<str<<endl;

    sleep(1);
  }

}

int main()
{
  pthread_t tid1,tid2;
  pthread_create(&tid1,nullptr,callback1,(void*)"thread 1");
  pthread_create(&tid2,nullptr,callback2,(void*)"thread 2");
  cout<<tid1<<"  线程1"<<endl;
  cout<<tid2<<"  线程2"<<endl;
  while(1)
  {
    cout<<"I am main pthread!!"<<endl;
    sleep(1);
  }

  pthread_join(tid1,nullptr);
  pthread_join(tid2,nullptr);
  return 0;
}
